﻿'
' Will Strohl (will.strohl@gmail.com)
' http://www.willstrohl.com
'
'Copyright (c) 2011, Will Strohl
'All rights reserved.
'
'Redistribution and use in source and binary forms, with or without modification, are 
'permitted provided that the following conditions are met:
'
'Redistributions of source code must retain the above copyright notice, this list of 
'conditions and the following disclaimer.
'
'Redistributions in binary form must reproduce the above copyright notice, this list 
'of conditions and the following disclaimer in the documentation and/or other 
'materials provided with the distribution.
'
'Neither the name of Will Strohl nor the names of its contributors may be 
'used to endorse or promote products derived from this software without specific prior 
'written permission.
'
'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
'EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
'OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
'SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
'INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
'TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 
'BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
'CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
'ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
'DAMAGE.
'

Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions

Imports WillStrohl.Modules.CodeCamp.SpeakerInfoMembers

Namespace WillStrohl.Modules.CodeCamp

    <Serializable()> _
    Public NotInheritable Class SpeakerInfo
        Implements ISpeakerInfo, IHydratable

#Region " Private Members "

        Private p_Author As Boolean = Null.NullBoolean
        Private p_Bio As String = Null.NullString
        Private p_CompanyName As String = Null.NullString
        Private p_CompanyTitle As String = Null.NullString
        Private p_CreatedByDate As DateTime = Null.NullDate
        Private p_CreatedByUser As Integer = Null.NullInteger
        Private p_IconFile As String = Null.NullString
        Private p_MicrosoftMVP As Boolean = Null.NullBoolean
        Private p_RegistrationId As Integer = Null.NullInteger
        Private p_SpeakerId As Integer = Null.NullInteger
        Private p_SpeakerName As String = Null.NullString
        Private p_URL As String = Null.NullString
        Private p_Approved As Boolean = Null.NullBoolean

#End Region

#Region " Public Properties "

        Public Property Author() As Boolean Implements ISpeakerInfo.Author
            Get
                Return Me.p_Author
            End Get
            Set(ByVal value As Boolean)
                Me.p_Author = value
            End Set
        End Property

        Public Property Bio() As String Implements ISpeakerInfo.Bio
            Get
                Return Me.p_Bio
            End Get
            Set(ByVal value As String)
                Me.p_Bio = value
            End Set
        End Property

        Public Property CompanyName() As String Implements ISpeakerInfo.CompanyName
            Get
                Return Me.p_CompanyName
            End Get
            Set(ByVal value As String)
                Me.p_CompanyName = value
            End Set
        End Property

        Public Property CompanyTitle() As String Implements ISpeakerInfo.CompanyTitle
            Get
                Return Me.p_CompanyTitle
            End Get
            Set(ByVal value As String)
                Me.p_CompanyTitle = value
            End Set
        End Property

        Public Property CreatedByDate() As Date Implements ISpeakerInfo.CreatedByDate
            Get
                Return Me.p_CreatedByDate
            End Get
            Set(ByVal value As Date)
                Me.p_CreatedByDate = value
            End Set
        End Property

        Public Property CreatedByUser() As Integer Implements ISpeakerInfo.CreatedByUser
            Get
                Return Me.p_CreatedByUser
            End Get
            Set(ByVal value As Integer)
                Me.p_CreatedByUser = value
            End Set
        End Property

        Public Property IconFile() As String Implements ISpeakerInfo.IconFile
            Get
                Return Me.p_IconFile
            End Get
            Set(ByVal value As String)
                Me.p_IconFile = value
            End Set
        End Property

        Public Property MicrosoftMVP() As Boolean Implements ISpeakerInfo.MicrosoftMVP
            Get
                Return Me.p_MicrosoftMVP
            End Get
            Set(ByVal value As Boolean)
                Me.p_MicrosoftMVP = value
            End Set
        End Property

        Public Property RegistrationId() As Integer Implements ISpeakerInfo.RegistrationId
            Get
                Return Me.p_RegistrationId
            End Get
            Set(ByVal value As Integer)
                Me.p_RegistrationId = value
            End Set
        End Property

        Public Property SpeakerId() As Integer Implements ISpeakerInfo.SpeakerId
            Get
                Return Me.p_SpeakerId
            End Get
            Set(ByVal value As Integer)
                Me.p_SpeakerId = value
            End Set
        End Property

        Public Property SpeakerName() As String Implements ISpeakerInfo.SpeakerName
            Get
                Return Me.p_SpeakerName
            End Get
            Set(ByVal value As String)
                Me.p_SpeakerName = value
            End Set
        End Property

        Public Property URL() As String Implements ISpeakerInfo.URL
            Get
                Return Me.p_URL
            End Get
            Set(ByVal value As String)
                Me.p_URL = value
            End Set
        End Property

        Public Property Approved As Boolean Implements ISpeakerInfo.Approved
            Get
                Return Me.p_Approved
            End Get
            Set(ByVal value As Boolean)
                Me.p_Approved = value
            End Set
        End Property

#End Region

        Public Sub New()
            ' do nothing
        End Sub

#Region " IHydratable Implementation "

        Public Property KeyID() As Integer Implements DotNetNuke.Entities.Modules.IHydratable.KeyID
            Get
                Return Me.p_SpeakerId
            End Get
            Set(ByVal value As Integer)
                Me.p_SpeakerId = value
            End Set
        End Property

        Public Sub Fill(ByVal dr As System.Data.IDataReader) Implements DotNetNuke.Entities.Modules.IHydratable.Fill
            Try
                While dr.Read
                    If Not dr.Item(AuthorField) Is Nothing Then
                        Me.p_Author = Boolean.Parse(dr.Item(AuthorField).ToString)
                    End If
                    If Not dr.Item(BioField) Is Nothing Then
                        Me.p_Bio = dr.Item(BioField).ToString
                    End If
                    If Not dr.Item(CompanyNameField) Is Nothing Then
                        Me.p_CompanyName = dr.Item(CompanyNameField).ToString
                    End If
                    If Not dr.Item(CompanyTitleField) Is Nothing Then
                        Me.p_CompanyTitle = dr.Item(CompanyTitleField).ToString
                    End If
                    If Not dr.Item(CreatedByDateField) Is Nothing Then
                        If IsDate(dr.Item(CreatedByDateField)) Then
                            Me.p_CreatedByDate = Date.Parse(dr.Item(CreatedByDateField).ToString)
                        End If
                    End If
                    If Not dr.Item(CreatedByUserField) Is Nothing Then
                        Me.p_CreatedByUser = Integer.Parse(dr.Item(CreatedByUserField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(IconFileField) Is Nothing Then
                        Me.p_IconFile = dr.Item(IconFileField).ToString
                    End If
                    If Not dr.Item(MicrsoftMVPField) Is Nothing Then
                        Me.p_MicrosoftMVP = Boolean.Parse(dr.Item(MicrsoftMVPField).ToString)
                    End If
                    If Not dr.Item(RegistrationIdField) Is Nothing Then
                        Me.p_RegistrationId = Integer.Parse(dr.Item(RegistrationIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(SpeakerIdField) Is Nothing Then
                        Me.p_SpeakerId = Integer.Parse(dr.Item(SpeakerIdField).ToString, Globalization.NumberStyles.Integer)
                    End If
                    If Not dr.Item(SpeakerNameField) Is Nothing Then
                        Me.p_SpeakerName = dr.Item(SpeakerNameField).ToString
                    End If
                    If Not dr.Item(URLField) Is Nothing Then
                        Me.p_URL = dr.Item(URLField).ToString
                    End If
                    If Not dr.Item(ApprovedField) Is Nothing Then
                        Me.p_Approved = Boolean.Parse(dr.Item(ApprovedField).ToString)
                    End If
                End While
            Catch ex As Exception
                LogException(ex)
            Finally
                If Not dr.IsClosed Then
                    dr.Close()
                End If
            End Try
        End Sub

#End Region

    End Class

End Namespace